#include "mapVectorBody.h"
#include <iostream>
using namespace std;

//mapVectorEntity--------------------------------
mapVectorEntity::mapVectorEntity(mapScreen *s) {
    activeMap = s;
}
mapVectorEntity::~mapVectorEntity() {
}
void mapVectorEntity::draw() {
    float r, g, b;
    gColor(&r, &g, &b);
    cairo_t* cr = activeMap->getCairoInstance();
    cairo_set_source_rgb(cr, r, g, b);

    vector<VectorPoint*>::iterator itr = getBegin();

    cairo_move_to(cr, (*itr)->getX() * activeMap->getLineWidth(), (*itr)->getY() * activeMap->getLineHeight());
    itr++;

    for (; itr != getEnd(); itr++) {
        cairo_line_to(cr, (*itr)->getX() * activeMap->getLineWidth(), (*itr)->getY() * activeMap->getLineHeight());
    }

    cairo_close_path(cr);
    cairo_fill(cr);
}
bool mapVectorEntity::onEvent(SDL_Event* event) {
    if (event->type == SDL_MOUSEBUTTONDOWN) {
        if (containsPoint(event->button.x / activeMap->getLineWidth(), event->button.y / activeMap->getLineHeight())) {
            return true;
        } else {
            cout.flush();
        }
    }
    return false;
}
void mapVectorEntity::onUpdate(float timeElapsed) {
    
}
//mapVectorEntity================================